package cloud.alibaba.controller;

import java.math.BigDecimal;
import java.util.Date;

import cloud.alibaba.entities.Pay;
import cloud.alibaba.service.PayService;
import cloud.alibaba.util.Result;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson2.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author dgg
 * @date 2024/7/8 19:39
 * @description:
 */
@Tag(name = "测试模块", description = "订单CRUD")
@RestController
@RequestMapping("/pay")
public class PayController {
    @Resource
    private PayService payService;

    @GetMapping("/get/all")
    @Operation(summary = "查询所有", description = "查询所有支付流水")
    public Result<List<Pay>> getAll() {
        List<Pay> pays = payService.getAll();
        return Result.success(pays);
    }

    @GetMapping("/get/one/{id}")
    @Operation(summary = "查询所有", description = "查询所有支付流水")
    public Result<Pay> getOne(@PathVariable("id") Integer id) {
        if (id > 1000) throw new RuntimeException("超出最大值！");
        Pay pay = new Pay();
        pay.setId(0);
        pay.setPayNo("");
        pay.setOrderNo("");
        pay.setUserId(0);
        pay.setAmount(new BigDecimal("0"));
        pay.setDeleted((byte) 0);
        pay.setCreateTime(new Date());
        pay.setUpdateTime(new Date());

        return Result.success(pay);
    }
}
